import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xvideos/hj_model/video_model.dart';
import 'package:xvideos/routers/jump_router.dart';
import 'package:xvideos/tools_base/widget/net_image_widget.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';

class ItemRenderConfig {
  final int? titleMaxLines;
  final bool showComment;
  const ItemRenderConfig({this.titleMaxLines, this.showComment = true});
}

/// 专题用横版视频item
class VideoHItem extends StatelessWidget {
  final VideoModel model;
  const VideoHItem({super.key, required this.model});
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () => pushToVideoPage(videoModel: model),
      child: SizedBox(
        height: 99.h,
        child: Row(
          children: [
            SizedBox(
              width: 174.w,
              child: Stack(
                alignment: Alignment.bottomCenter,
                children: [
                  NetworkImageLoader(
                    imageUrl: model.cover ?? '',
                    width: double.infinity,
                    height: double.infinity,
                    borderRadius: 6,
                  ),
                  Container(
                    height: 18.h,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.vertical(bottom: Radius.circular(6)),
                      gradient: LinearGradient(
                          colors: [Colors.transparent, Color(0x99000000)], begin: Alignment.topCenter, end: Alignment.bottomCenter),
                    ),
                    padding: EdgeInsets.symmetric(horizontal: 8.w),
                    child: Row(
                      children: [
                        Text(
                          '${model.playCount.humanizeFormat}播放 ',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.sp,
                          ),
                        ),
                        Spacer(),
                        Text(
                          '${model.playTime.timeMSFormat}',
                          style: TextStyle(
                            color: Colors.white,
                            fontSize: 12.sp,
                          ),
                        )
                      ],
                    ),
                  )
                ],
              ),
            ),
            14.w.sizeBoxW,
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  7.h.sizeBoxH,
                  Expanded(
                    child: Column(
                      children: [
                        Text(
                          model.title ?? '',
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(color: Colors.white, fontSize: 14.sp, fontWeight: FontWeight.w500),
                        ),
                        // 4.h.sizeBoxH,
                        Spacer(),
                        Text(
                          model.summary ?? '',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(color: Color(0x99ffffff), fontSize: 12.sp, fontWeight: FontWeight.w400),
                        ),
                      ],
                    ),
                  ),
                  4.h.sizeBoxH,
                  Row(
                    children: [
                      Text(
                        '${model.tags?.firstOrNull?.name ?? ''}',
                        style: TextStyle(color: Color(0x99FFFFFF), fontSize: 12.sp, fontWeight: FontWeight.w400),
                      ),
                      Spacer(),
                      Text(
                        '评论${model.commentCount.humanizeFormat}',
                        style: TextStyle(color: Color(0x99FFFFFF), fontSize: 12.sp, fontWeight: FontWeight.w400),
                      )
                    ],
                  ),
                  7.h.sizeBoxH,
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
